package com.henu.art.service.Imlp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.henu.art.entity.Research;
import com.henu.art.mapper.ResearchMapper;
import com.henu.art.service.ResearchService;
import com.henu.art.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ResearchServiceImpl extends ServiceImpl<ResearchMapper, Research> implements ResearchService {
    @Override
    public IPage<Research> getResearchPage(Integer pageNum, Integer pageSize) {
        return this.page(new Page<>(pageNum, pageSize));
    }

    @Override
    public IPage<Research> getResearchPageById(String id, Integer pageNum, Integer pageSize) {
        QueryWrapper<Research> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        return this.page(new Page<>(pageNum, pageSize), queryWrapper);
    }

    @Override
    public Result<?> deleteResearch(Long id) {
        return this.removeById(id) ? Result.ok("删除成功") : Result.error("删除失败");
    }
}